package com.pc.web.board;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;


@Repository
public class BoardDAO {
	@Autowired private SqlSession sql;
	public int insert(BoardBeans beans){
		return sql.insert("board.insert", beans);
	}
	//리스트
	public List<BoardBeans> select(){
		return sql.selectList("board.select");
	}
	//글 상세보기
	public BoardBeans detailView(String board_no) {
		return sql.selectOne("board.detailView", board_no);
	}
	//글 수정상세보기
	public BoardBeans modifyView(String board_no) {
		return sql.selectOne("board.modifyView", board_no);
	}
	//글 업데이트
	public int update(BoardBeans beans) {
		return sql.update("board.modify", beans);
	}
	//글 삭제
	public void delete(String board_no) {
		sql.delete("board.delete", board_no);
	}
	//글 총수
	public int getListCount(){
		return sql.selectOne("board.listcount");
	}
	public List<BoardBeans> getBoardList(BoardBeans beans){
		return sql.selectList("board.boardlist", beans);
	}
	//조회수 업데이트
	public void countUpdate(String board_no){
		sql.update("board.countUpdate", board_no);
	}
	//댓글삭제
	public void commentDelete(String board_number){
		sql.delete("board.commentDelete", board_number);
	}
	//덧글입력
	public int commentInsert(BoardBeans beans){
		return sql.insert("board.comment", beans);
	}
	//댓글 리스트
	public List<BoardBeans> commentView(String board_no) {
		return sql.selectList("board.commentView", board_no);
	}
	//댓글 가져오기
	public List<String> commentList(String board_no){
		return sql.selectList("board.commentList", board_no);
	}
}